Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force grab/ungrab keyboard+mouse with Right Ctrl key #1906

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

phd
Copy link

@phd phd commented Feb 6, 2025

Force grab/ungrab keyboard+mouse with Right Ctrl key,
Allows for control integration similar to what VirtualBox does.

Solves pointer movement glitches with applications that require grabbing the mouse internally
(like modern web browsers using the Pointer Lock API).

Test:

  1. Open any modern web browser inside TigerVNC viewer.
  2. Navigate to https://mdn.github.io/dom-examples/pointer-lock/
  3. Click on the red dot and move the mouse far (off-screen) in any direction.

Without this patch the above website works only in TigerVNC viewer's fullscreen mode.

Copy link
Member

@CendioOssman CendioOssman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your suggestion!

Like the pointer lock API, we'd rather avoid pestering the user with this. We already have support for the pointer warp extension. And there is a relative mouse movement extension from QEMU that we could start supporting. Those would allow a more natural and automatic user experience.

Have you had a look at those?

@phd
Copy link
Author

phd commented Feb 16, 2025

I have no experience with the VNC protocol nor its extensions.
Just wanted to fix the Pointer Lock API issue and this solution works well for me while being very intuitive. That's why I wanted to share it.
It does not affect user experience in any way other than adding this key binding, so it won't pester users not willing to use it.
Meanwhile it allows to comfortably use TigerVNC with clients that require Pointer Lock API or other forms of pointer positioning. And it does it right now. When a proper solution is implemented this could be removed (or reduced to forced grab/ungrab which could still be useful e.g. for handling system-wide shortcuts).

@phd phd force-pushed the phd-force-grab branch 3 times, most recently from 7c36c88 to b4971c8 Compare February 24, 2025 19:25
@CendioOssman
Copy link
Member

The test case you have seems to work fine with the existing support in TigerVNC for relative mouse movements. So I think I misunderstood what this PR actually changes.

The focus is rather to allow grabs in windowed mode. The big problem with that is adding more key bindings means more risk of conflict with what applications need. Have you looked at the existing discussion in #102? And the work in progress in #1375?

The proposed plan there tries to minimize the conflict, and provides a way out in case a conflict still arises.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants